package com.woniuxy.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.anno.LogAnnotation;
import com.woniuxy.entity.InfoLog;
import com.woniuxy.service.IInfoLogService;
import com.woniuxy.util.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * @author：xurice
 * @date：Created in 2024/3/2 11:16
 * @description：
 * @modified By：
 * @version: $
 */
@Controller
@RequestMapping("log")
public class InfoLogController {
    @Autowired
    IInfoLogService iInfoLogService;
    @RequestMapping("queryList")
    @ResponseBody
    @LogAnnotation
    public ResponseData<?> queryList(@RequestParam(defaultValue = "1") Integer pageNum,
                                  @RequestParam(defaultValue = "10") Integer pageSize,
                                  String username,
                                  @DateTimeFormat(pattern = "yyyy-MM-dd")
                             Date beginTime,
                                  @DateTimeFormat(pattern = "yyyy-MM-dd")
                             Date endTime){
        if (endTime!=null){
            endTime.setTime(endTime.getTime()+24*60*60*1000-1);
        }

        PageInfo<InfoLog> pageInfo = iInfoLogService.getPageInfo(pageNum, pageSize, username, beginTime, endTime);
        return new ResponseData<>(200,"ok",pageInfo);

    }
}
